#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/12/21 20:54
# @Author: hekang
# @Email: 591785757@qq.com
# @File：finance_page.py
"""
财务页
"""
from selenium.webdriver.common.by import By
from pages.base_page import BasePage


class Finance(BasePage):
    # 定位器
    recycle_locator = (  # 定位"回收站"
        By.XPATH, "/html/body/div[5]/p/a[14]")
    all_locator = (  # 定位"全选"
        By.CLASS_NAME, "check_all")
    delete_locator = (  # 定位"删除"
        By.ID, "delete")
    add_locator = (  # 定位"添加应收款"
        By.CLASS_NAME, "btn-primary")
    MyCreate_locator = (  # 定位"我创建的"
        By.CSS_SELECTOR, "body > div.container > p > a:nth-child(5)")

    # 点击"回收站"
    def finance_recycle(self):
        self.driver.find_element(*self.recycle_locator).click()

    # 点击"全选"
    def finance_all(self):
        self.driver.find_element(*self.all_locator).click()

    # 点击"删除"
    def finance_delete(self):
        self.driver.find_element(*self.delete_locator).click()
        self.driver.switch_to.alert.accept()

    # 点击"添加应收款"
    def finance_add(self):
        self.driver.find_element(*self.add_locator).click()

    # 点击"我创建的"
    def finance_mycreate(self):
        self.driver.find_element(*self.MyCreate_locator).click()
